import Vue from 'vue'
import App from './App.vue'
import axios from 'axios'
import VueAxios from "vue-axios";
import router from './router'
import env from './env';  //自定义js同级陌路下引入需要加./

Vue.use(VueAxios, axios);
Vue.config.productionTip = false;

//根据前端的跨域方式做调整
axios.defaults.baseURL = '/api';
axios.defaults.timeout = 8000;

//根据环境变量获取不同的请地址
axios.defaults.baseURL = env.baseUrl;

//请求拦截
axios.interceptors.request.use();

// 接口错误拦截
axios.interceptors.response.use(function (response) {
    let res = response.data;
    if (res.status == 0) {
        return res.data;
    } else if (res.status == 10) {
        window.location.href = '/#/login';
    } else {
        alert(res.msg);
    }
});


new Vue({
    //一般都是在main.js加载路由
    router,
    render: h => h(App),
}).$mount('#app');
